#include "collections.h"



using namespace collections;


void Ind0ChainMbr::_pop()
{
	if (_mPrev)
		_mPrev->_setNext(_mNext);
	else //item was first
		_mOwner->_setFirst(_mNext);
	
	if (_mNext)
		_mNext->_setPrev(_mPrev);
	else //item was last
		_mOwner->_setLast(_mPrev);

	_mOwner->_decSize();
	_mOwner = NULL;
}


Ind0Chain::~Ind0Chain()
{
	if (mBorrow)
		return;

	iterator it = begin();
	while (it != end())
	{
		Ind0ChainMbr* item = *it;
		it++;
		item->_pop();
		delete item;
	}
}

void Ind0Chain::push_front(Ind0ChainMbr* item)
{
	item->_setNext(mFirst);
	if (mFirst)
		mFirst->_setPrev(item);
	else //la chaine est vide
		mLast = item;
	mFirst = item;
	mCount++;
	item->_setOwner(this);
}
